from typing import *

class Solution:
    def getWordsInLongestSubsequence(self, n: int, words: List[str], groups: List[int]) -> List[str]:
        ans,c = [], -1
        for w,g in zip(words,groups):
            if g != c:
                ans.append(w)
                c = g
        return ans